package com.project.dao.impl;

import java.sql.SQLException;
import java.util.List;

import com.project.common.util.QueryUtils;
import com.project.dao.ISearchDao;
import com.project.webapp.form.front.preSchool.ArticleForm;
import com.project.webapp.form.front.preSchool.SearchForm;

/**
 * 课程Search Dao Implement实现
 * @author Sn
 *
 */
public class SearchDao extends BaseDaoImpl implements ISearchDao 
{

	@SuppressWarnings("unchecked")
	@Override
	public QueryUtils search(QueryUtils queryutils) 
	{
		//System.out.println("我进入了搜索的DAO");
		List<ArticleForm> articlelist = null;
		try {	
			//获取总的页数
			Long count=Long.parseLong(this.getSqlMapClient().queryForObject("searchcount", (SearchForm)queryutils.getObj()).toString());
			//将页数封装到queryUtils中去
			queryutils.setPagetotal(count);
			//将queryutils中的条件，也就是obj中封装的对象传递mapsql中去
			SearchForm search=(SearchForm) queryutils.getObj();
			//设置当前从第几条开始
			search.setNum1(queryutils.getIndexlastsum());
			//设置每页显示多少条信息
			search.setNum2(queryutils.getPagesize());
			//取回查询到的数据
			articlelist = this.getSqlMapClient().queryForList("searchfromMap", search);
		} catch (SQLException e) 
		{
			e.printStackTrace();
		}
		//将查询到的数据封装到queryutils中去，并且返回对应的数据
		queryutils.setPagelist(articlelist);
		return queryutils;
	}
		
}
